package com.ysd.lis.controller.lab;


import com.ysd.common.Result;
import com.ysd.lis.annotation.LogDetail;
import com.ysd.lis.aspect.OperationType;
import com.ysd.lis.controller.pub.BaseController;
import com.ysd.lis.entity.lab.LabMainState;
import com.ysd.lis.entity.lab.LabMaininfo;
import com.ysd.lis.entity.lab.LabReqMain;
import com.ysd.lis.entity.lab.LabReqState;
import com.ysd.lis.request.DeleteParam;
import com.ysd.lis.request.lab.LabProcessSetParam;
import com.ysd.lis.service.lab.LabMainStateService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * LAB_MAININFO的状态表 前端控制器
 * </p>
 *
 * @author Bai
 * @since 2024-01-16
 */
@RestController
@RequestMapping("/lab/mainState")
public class LabMainStateController extends BaseController {

    @Autowired
    private LabMainStateService mainStateService;

    @ApiOperation("获取状态信息列表")
    @GetMapping("/findMainStateList")
    public Result findMainStateList() {
        return Result.succ(mainStateService.list());
    }

    @ApiOperation("根据状态id获取状态信息")
    @GetMapping("/findMainStateById/{id}")
    public Result findMainStateById(@PathVariable("id") String id) {
        return Result.succ(mainStateService.getById(id));
    }

    @ApiOperation("添加状态")
    @PostMapping("/addMainState")
    @LogDetail(requestParam = "addMainState", operationType = OperationType.INSERT, module = "检验系统", content = "新增【stateValue】状态", businessName = "stateValue")
    public Result addMainState(@RequestBody LabMainState bacMainState) {
        return Result.succ(mainStateService.save(bacMainState));
    }

    @ApiOperation("编辑状态")
    @PostMapping("/edit")
    @LogDetail(requestParam = "edit", operationType = OperationType.UPDATE, module = "检验系统", content = "修改【stateValue】状态", businessName = "stateValue")
    public Result edit(@RequestBody LabMainState bacMainState) {
        return Result.succ(mainStateService.updateById(bacMainState));
    }

    @ApiOperation("根据ids批量删除状态")
    @PostMapping("/deleteMainState")
    @LogDetail(requestParam = "deleteMainState", operationType = OperationType.DELETE, module = "检验系统", content = "删除【names】抗生素", businessName = "names")
    public Result deleteMainState(@RequestBody DeleteParam deleteParam) {
        return mainStateService.deleteMainState(deleteParam);
    }

    // @ApiOperation("获取状态信息列表（统计1）")
    // @GetMapping("/getTraceRecList")
    // public Result getTraceRecList(LabMaininfo labMaininfo){
    //     return mainStateService.getTraceRecList(labMaininfo);
    // }
    @ApiOperation("获取状态信息列表（统计2）")
    @GetMapping("/getTraceRecTwoList")
    public Result getTraceRecTwoList(LabProcessSetParam input) {
        return mainStateService.getTraceRecTwoList(input);
    }

    @ApiOperation("获取闭环信息")
    @GetMapping("/getClosedLoopList")
    public Result getClosedLoopList(LabProcessSetParam input) {
        return mainStateService.getClosedLoopList(input);
    }

}